import base64
import grpc
import data_pb2
import data_pb2_grpc

def run():
    conn = grpc.insecure_channel('localhost:10086', options=[
        ('grpc.max_send_message_length', 255*1024*1024),   # 修改数据传输的大小限制
        ('grpc.max_receive_message_length', 256*1024*1024),
    ])  # 监听频道
    client = data_pb2_grpc.FormatDataStub(channel=conn)
    with open('input.png', 'rb') as f:
        content = f.read()

    content = str(base64.b64encode(content), encoding='utf-8')
    response = client.DoFormat(data_pb2.request(img=content))
    print("reveived: "+response.msg)


if __name__ == '__main__':
    run()

